package com.ruoyi.common.utils;

import java.util.Random;
import java.util.UUID;

/**
 * @description： 随机生成工具类
 * @author:zxx
 * @date:2021/5/17 0017
 */
public class RandomUtil {
    /**
     * 随机生成7、8、9、10位的账号
     *
     * @return
     */
    public static String randomAccount() {
        Random random = new Random();
        StringBuffer buffer = new StringBuffer();
        int up = random.nextInt(11 - 7) + 7;
        for (int i = 0; i < up; i++) {
            buffer.append(random.nextInt(9) + 1 + "");
        }
        return buffer.toString();
    }

    /**
     * 随机生成六位数的验证码
     *
     * @return
     */
    public static String randomAuthCode() {
        Random random = new Random();
        StringBuffer buffer = new StringBuffer();
        for (int i = 1; i <= 6; i++) {
            buffer.append(random.nextInt(9) + 1 + "");
        }
        return buffer.toString();
    }

    /**
     * 随机生成主键
     *
     * @return
     */
    public static String randomUUID() {
        return UUID.randomUUID().toString().substring(2, 11);
    }
    /**
     * 随机生成主键
     *
     * @return
     */
    public static String randomID() {
        return UUID.randomUUID().toString().substring(2, 8);
    }

    /**
     * @param i
     * @return
     */
    public static String randomUUID(Integer i) {
        return UUID.randomUUID().toString().substring(2, i);
    }


}
